package com.burstly.lib.network.request;

import com.burstly.lib.constants.UriConstants;
import com.burstly.lib.currency.request.RequestWrapper;
import com.burstly.lib.service.HostsProviderManager;
import com.burstly.lib.util.LoggerExt;
import com.burstly.lib.util.Utils;

public class CurrencyRequestTask<T> extends BurstlyRequestTask<T>
  implements IRequestCallback<T>
{
  private static final String CURRENCY_REQUEST_TASK = "CurrencyRequestTask";
  private static final String ENCRYPTION_KEY = "";
  private static final LoggerExt LOG = LoggerExt.getInstance();
  private static final int MINUTE_TIMEOUT = 60000;
  private static final String TAG = "CurrencyRequestTask";
  private Object mRequest;
  T mResponse;
  private String mSerializedRequest;
  private long mSleepInterval;
  private boolean mUseEncryption;

  public CurrencyRequestTask(Object paramObject, Class<T> paramClass)
  {
    super(null, UriConstants.CURRENCY_SECURED_POINT, paramClass, "CurrencyRequestTask");
    this.mUseEncryption = true;
    setUpRequestTask(paramObject);
    setUseRequestCycle(false);
    setHostProvider(HostsProviderManager.getCurrencyProvider());
  }

  public CurrencyRequestTask(String paramString, Object paramObject, Class<T> paramClass)
  {
    super(null, paramString, paramClass, "CurrencyRequestTask");
    setUpRequestTask(paramObject);
  }

  private static String removeTrailingZeroBytes(String paramString)
  {
    int i = paramString.indexOf(0);
    if (i != -1)
      paramString = paramString.substring(0, i);
    return paramString;
  }

  private void setUpRequestTask(Object paramObject)
  {
    setRequest(paramObject);
    setCanBeAborted(false);
    setCallback(this);
    this.mSleepInterval = 60000L;
  }

  protected T convertServerResponse(String paramString)
  {
    if (paramString == null)
      return null;
    Object localObject = paramString.replaceAll("\"", "");
    if (this.mUseEncryption);
    try
    {
      String str = Utils.decrypt("", (String)localObject);
      localObject = str;
      return Utils.fromJson(removeTrailingZeroBytes((String)localObject), getTartgetClass());
    }
    catch (Exception localException)
    {
      while (true)
        LOG.logThrowable("CurrencyRequestTask", localException);
    }
  }

  public T executeInThisThread()
  {
    doInBackground(new Void[0]);
    return this.mResponse;
  }

  protected String getDataToPost()
  {
    if (this.mSerializedRequest == null);
    try
    {
      this.mSerializedRequest = Utils.toJson(this.mRequest);
      if (this.mUseEncryption)
      {
        this.mSerializedRequest = Utils.encryp("", this.mSerializedRequest);
        this.mSerializedRequest = Utils.toJson(new RequestWrapper(this.mSerializedRequest));
      }
      this.mRequest = null;
      return this.mSerializedRequest;
    }
    catch (Exception localException)
    {
      while (true)
      {
        LOG.logThrowable("CurrencyRequestTask", localException);
        this.mSerializedRequest = "";
      }
    }
  }

  protected Object getRequest()
  {
    return this.mRequest;
  }

  protected long getSleepBetweenRequestCycles()
  {
    this.mSleepInterval = (2L * this.mSleepInterval);
    return this.mSleepInterval;
  }

  public void onFailInBackground(T paramT)
  {
  }

  public void onFailUi(T paramT)
  {
  }

  public void onNoConnection()
  {
  }

  public void onSuccessInBackground(T paramT)
  {
    this.mResponse = paramT;
  }

  public void onSuccessUi(T paramT)
  {
  }

  public void preExecute()
  {
  }

  protected void setRequest(Object paramObject)
  {
    this.mRequest = paramObject;
  }

  public void setUseEncryption(boolean paramBoolean)
  {
    this.mUseEncryption = paramBoolean;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.network.request.CurrencyRequestTask
 * JD-Core Version:    0.6.2
 */